/*
ID : phamnamlo2
LANG : C++
PROB : ride
*/

#include <iostream>
#include <string>

using namespace std;

string a;
int s[2];

main()
{
  freopen("ride.in", "r", stdin);
  freopen("ride.out", "w", stdout);
   
  for (int i = 0; i < 2; i++)
  {
    cin >> a;
    s[i] = 1;
    for (int j = 0; j < a.size(); j++) s[i] *= a[j] - 64;
    s[i] %= 47;
  }
  if (s[0] == s[1]) cout << "GO"; else cout << "STAY";
  cout << endl;
  
  return 0;
}
